/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.controller.employee;

import com.entity.Employee;
import com.model.EmployeeModel;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author Tuan Long
 */
@Named(value = "employeeManager")
@RequestScoped
public class EmployeeManager {

    public EmployeeManager() {
    }

    private Employee employee;
    private String fullname;

    public String getFullname() {
        return fullname;
    }

    public void setFullname(String fullname) {
        this.fullname = fullname;
    }

    public Employee getEmployee() {
        getEmployeeInfoByUsername();
        return employee;
    }
    private String username;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    /**
     *
     */
    public void getEmployeeInfoByUsername() {
        HttpServletRequest req = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
        username = req.getParameter("emId");
        EmployeeModel model = new EmployeeModel();
        if (username != null) {
            employee = model.getEmployeeInfoByUsername(username);
        }
    }
}
